<template>
  <div class="right-bottom-content">
    <div class="top-num m-t-12">
      <div class="top-num-cont">
        <div class="top-num-cont-img"></div>
        <div class="top-num-cont-right">
          <div class="n-c-title">
            运行实例总量
            <div class="n-c-num">205</div>
          </div>
        </div>
      </div>
      <div class="top-num-cont">
        <div class="top-num-cont-img"></div>
        <div class="top-num-cont-right">
          <div class="n-c-title">
            运行GPU总量
            <div class="n-c-num">1600</div>
          </div>
        </div>
      </div>
      <div class="top-num-cont">
        <div class="top-num-cont-img"></div>
        <div class="top-num-cont-right">
          <div class="n-c-title">
            运行时长
            <div class="n-c-num">154</div>
          </div>
        </div>
      </div>
    </div>
    <div class="hashrate">
      <div class="hashrate-flex m-t-20">
        <div class="h-f-item">
          <!-- 运行实例总数 -->
          <v-chart class="chart" :option="instance_num_option" />
        </div>
        <div class="h-f-item">
          <!-- 运行GPU总数 -->
          <v-chart class="chart" :option="gpu_num_option" />
        </div>
      </div>
      <div class="time-item m-t-12">
        <!-- 运行时长 -->
         <v-chart class="chart" :option="run_time_option" />
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import {getLast7Days, generateRates} from '@/utils/publicMethod'
const instance_num_option = ref({
  title: {
      text: '运行实例总数（近7天）',
      left: 'center',
      textStyle: {
          color: '#D3D6DD',
          fontSize: 16,
      }
  },
  tooltip: {
      trigger: 'axis',
      axisPointer: {
          type: 'shadow'
      },
      formatter: '{b}<br/>运行实例: {c}台'
  },
  grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
  },
  xAxis: {
      type: 'category',
      data: getLast7Days(),
      axisLabel: {
          rotate: 30, // 如果日期太长可以旋转30度
          color: '#D3D6DD'
      },
      axisLine: {
          lineStyle: {
              color: '#ccc'
          }
      }
  },
  yAxis: {
      type: 'value',
      name: '实例总数(台)',
      nameTextStyle: {
          color: '#D3D6DD' // 纵轴名称颜色改为白色
      },
      axisLabel: {
          formatter: '{value}',
          color: '#D3D6DD'
      },
      splitLine: {
          // lineStyle: {
          //     type: 'dashed'
          // }
          show: false // 关闭分割线
      }
  },
  series: [{
      name: '实例总数',
      type: 'bar',
      barWidth: '40%',
      data: [134, 89, 178, 190, 203, 234, 205],
  }]
})
const gpu_num_option = ref({
  title: {
      text: '运行GPU总数（近7天）',
      left: 'center',
      textStyle: {
          color: '#D3D6DD',
          fontSize: 16,
      }
  },
  tooltip: {
      trigger: 'axis',
      axisPointer: {
          type: 'shadow'
      },
      formatter: '{b}<br/>运行GPU: {c}'
  },
  grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
  },
  xAxis: {
      type: 'category',
      data: getLast7Days(),
      axisLabel: {
          rotate: 30, // 如果日期太长可以旋转30度
          color: '#D3D6DD'
      },
      axisLine: {
          lineStyle: {
              color: '#ccc'
          }
      }
  },
  yAxis: {
      type: 'value',
      name: 'GPU总数',
      nameTextStyle: {
          color: '#D3D6DD' // 纵轴名称颜色改为白色
      },
      axisLabel: {
          formatter: '{value}',
          color: '#D3D6DD'
      },
      splitLine: {
          show: false // 关闭分割线
      }
  },
  series: [{
      name: 'GPU总数',
      type: 'bar',
      barWidth: '40%',
      data: [134, 89, 178, 190, 203, 234, 205],
  }]
})
const run_time_option = ref({
  title: {
    text: '运行时长（近7天）',
    left: 'center',
      textStyle: {
          color: '#D3D6DD',
          fontSize: 16,
      }
  },
  tooltip: {
      trigger: 'axis',
      axisPointer: {
          type: 'shadow'
      },
      formatter: '{b}:{c}小时'
  },
  xAxis: {
    type: 'category',
    data: getLast7Days(),
    axisLine: {
      lineStyle: {
        color: '#D3D6DD'
      }
    },
    axisLabel: {
      color: '#D3D6DD'
    }
  },
  yAxis: {
    type: 'value',
    name: '小时',
    nameTextStyle: {
      color: '#D3D6DD',
      padding: [0, 0, 0, 30] // 调整单位位置
    },
    axisLine: {
      lineStyle: {
        color: '#D3D6DD',
        show: true
      }
    },
    axisLabel: {
      color: '#D3D6DD',
      formatter: '{value}' // 可以自定义格式，这里保持原样
    },
    splitLine: {
      lineStyle: {
        color: 'rgba(211, 214, 221, 0.2)' // 浅色分割线
      }
    }
  },
  series: [
    {
      data: [10, 13, 8, 18, 20, 11, 12],
      type: 'line',
      smooth: true,
      lineStyle: {
        color: '#5B8FF9', // 线条颜色
        width: 3
      },
      symbol: 'circle', // 数据点形状
      symbolSize: 8,
      itemStyle: {
        color: '#5B8FF9' // 数据点颜色
      },
    }
  ],
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    top: '15%',
    containLabel: true
  }
})
</script>
<style scoped lang="scss">
.right-bottom-content {
  .top-num {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    .top-num-cont {
      width: calc(100% / 3 - 10px);
      display: flex;

      .top-num-cont-img {
        width: 35%;
        height: 100%;
        margin-right: 5%;
        background-image: url("@/assets/img/left_top_huang.png");
      }
      .top-num-cont-right {
        flex: 1;
        .n-c-title {
          font-size: 14px;
        }
        .n-c-num {
          font-size: 20px;
          font-weight: bold;
        }
      }
    }
  }
  .hashrate {
    .hashrate-flex {
        display: flex;
      justify-content: space-between;
      gap: 10px;
      .h-f-item {
        width: calc(100% / 2 - 10px);
        height: 200px;
      }
    }
    .time-item {
      width: 100%;
      height: 200px;
    }
  }
}
</style>